import java.io.Serializable;

public class User implements Serializable {
	static final long serialVersionUID = 1L;
	int ilen;
	int[] items;
	byte[] votes;

	User(int ilen) {
		this.ilen = ilen;
		items = new int[ilen];
		votes = new byte[ilen];
	}

	byte getVote(int inputItemID) {
		for (int v = 0; v < ilen; v++) {
			if (items[v] == inputItemID) {
				return votes[v];
			}
		}
		return -1;
	}

	byte voteGet(int inputItemID) {
		if (inputItemID > items[ilen - 1]) {
			return -1;
		}
		for (int i = 0; i < ilen; i++) {
			if (items[i] == inputItemID) {
				return votes[i];
			}
			if (inputItemID < items[i]) {
				return -1;
			}
		}
		return -1;
	}

	void sort() {
		quicksort(0, ilen - 1);
	}

	void quicksort(int low, int high) {
		int i = low;
		int j = high;
		int pivot = items[low + (high - low) / 2];

		while (i <= j) {
			while (items[i] < pivot) {
				i++;
			}
			while (items[j] > pivot) {
				j--;
			}

			if (i <= j) {
				int tempItem = items[i];
				items[i] = items[j];
				items[j] = tempItem;

				byte tempVote = votes[i];
				votes[i] = votes[j];
				votes[j] = tempVote;

				i++;
				j--;
			}
		}

		if (low < j) {
			quicksort(low, j);
		}
		if (i < high) {
			quicksort(i, high);
		}
	}
}